using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Instedd.Labs.GeoBlogging.WebApplication;

namespace Instedd.Labs.Geoblogging.Website
{
    public partial class AddComment : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                String itemGuid = Request.Form["itemGuid"];
                if (String.IsNullOrEmpty(itemGuid))
                {
                    return;
                }
                DataAccess.AddCommentEntry(new Guid(itemGuid), edCommentText.Text, DateTime.Now, edCommentName.Text);
            }
        }

        public String GetItemId()
        {
            String itemId = Request.QueryString["id"];
            if (!String.IsNullOrEmpty(itemId))
            {
                return Request.QueryString["id"];
            }
            return null;
        }

        protected override void OnPreRender(EventArgs e)
        {
            if (this.IsPostBack)
            {
                edCommentName.Text = "";
                edCommentText.Text = "";
            }
            base.OnPreRender(e);
        }
    }
}